﻿#include <windows.h>
#include <list>
#include <tchar.h>
using namespace std;
#include "../../../../NetEngine_Windows/NetEngine_SourceCode/XyRyNet_CommHdr.h"
#include "../../../../NetEngine_Windows/NetEngine_SourceCode/XyRyNet_ProtocolHdr.h"
#include "../../../../NetEngine_Windows/NetEngine_SourceCode/NetEngine/NetEngine_Core/NetCore_Define.h"
#include "../../../../NetEngine_Windows/NetEngine_SourceCode/NetEngine/NetEngine_Core/NetCore_Error.h"

#pragma comment(lib,"Ws2_32.lib")
#pragma comment(lib,"../../../../NetEngine_Windows/NetEngine_SourceCode/Debug/NetEngine_Core.lib")

int main()
{
	WSADATA st_WSAData;
	WSAStartup(MAKEWORD(2, 2), &st_WSAData);

	XNETHANDLE xhToken = 0;
	if (!NetCore_UDPSelect_Init(&xhToken, 5000))
	{
		printf("NetCore_UDPSelect_Init:%lX\n", NetCore_GetLastError());
		return 0;
	}
	while (1)
	{
		int nMsgLen = 2048;
		TCHAR tszMsgBuffer[2048];
		TCHAR tszClientAddr[64];

		memset(tszMsgBuffer, '\0', sizeof(tszMsgBuffer));
		memset(tszClientAddr, '\0', sizeof(tszClientAddr));

		NetCore_UDPSelect_Recv(xhToken, tszClientAddr, tszMsgBuffer, &nMsgLen, TRUE);
		Sleep(1000);
	}

	WSACleanup();
	return TRUE;
}